// custom-tab-bar/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    selected:0,
    tabList:[
      {
        "pagePath": "pages/first_page/first_page",
        "text": "寄件"
      },
      {
        "pagePath": "pages/tail_wind/tail_wind",
        "text": "学习中心"
      },
      {
        "pagePath": "pages/home_page/home_page",
        "text": "代收"
      }
  ]

  },

  /**
   * 组件的方法列表
   */
  methods: {
    switchTab(e){
      console.log(this.data)
      let key = Number(e.currentTarget.dataset.index);
      let tabList = this.data.tabList;
      let selected = this.data.selected;

      if(selected !== key){
        this.setData({
          selected:key
        });
        wx.switchTab({
          url: `/${tabList[key].pagePath}`,
        })
      }
    }
  }
})
